<template>
  <el-row :gutter="40" class="panel-group">
    <div style="margin-bottom: 25px;padding: 0px 20px;">
      <div class="card-panel" style="height: 65px;" v-if="erinfo">
        <span style="padding: 18px;display: block;font-size: 24px;">
          <span style="color:red" v-if="erinfo.erLevel==1">
            当前空气质量预警一级(红色)
          </span>
          <span style="color:#E9967A" v-if="erinfo.erLevel==2">
            当前空气质量预警二级(橙色)
          </span>
          <span style="color:#ffff00" v-if="erinfo.erLevel==3">
            当前空气质量预警三级(黄色)
          </span>
          <span style="color:rgb(23, 218, 120);font-size: 20px;">&nbsp;&nbsp;允许{{erinfo.vehicle}}车辆通行</span><span
            style="float: right;font-size: 18px;margin-right: 10px;"><span
              style="display: block;float: left;">云平台连接状态：</span><span style="color: springgreen;"><span
                class="circle">&nbsp;</span>&nbsp;&nbsp;畅通</span></span></span>

      </div>
      <div class="card-panel" style="height: 65px;" v-if="!(erinfo)">

        <span style="padding: 18px;display: block;font-size: 24px;">
          当前无预警
          <span style="float: right;font-size: 18px;margin-right: 10px;"><span
              style="display: block;float: left;">云平台连接状态：</span><span style="color: springgreen;"><span
                class="circle">&nbsp;</span>&nbsp;&nbsp;畅通</span></span></span>

      </div>
    </div>
    <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col">
      <div class="card-panel" @click="handleSetLineChartData('shoppings')">
        <div class="card-panel-icon-wrapper icon-shopping">
          <svg-icon icon-class="reg" class-name="card-panel-icon" />
        </div>
        <div class="card-panel-description">
          <div class="card-panel-text">
            已登记运输车辆
          </div>
          <count-to :start-val="0" :end-val="indexvo.truckCount" :duration="50" class="card-panel-num" />
        </div>
      </div>
    </el-col>
    <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col">
      <div class="card-panel" @click="handleSetLineChartData('newVisitis')">
        <div class="card-panel-icon-wrapper icon-people">
          <svg-icon icon-class="inout" class-name="card-panel-icon" />
        </div>
        <div class="card-panel-description">
          <div class="card-panel-text">
            运输车辆通行次数
          </div>
          <count-to :start-val="0" :end-val="indexvo.truckAccessCount" :duration="165" class="card-panel-num" />
        </div>
      </div>
    </el-col>
    <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col">
      <div class="card-panel" @click="handleSetLineChartData('purchases')">
        <div class="card-panel-icon-wrapper icon-money">
          <svg-icon icon-class="truck" class-name="card-panel-icon" />
        </div>
        <div class="card-panel-description">
          <div class="card-panel-text">
            场内运输车辆数量
          </div>
          <count-to :start-val="0" :end-val="indexvo.truckInnerCount" :duration="5" class="card-panel-num" />
        </div>
      </div>
    </el-col>


    <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col">
      <div class="card-panel" @click="handleSetLineChartData('messages')">
        <div class="card-panel-icon-wrapper icon-message">
          <svg-icon icon-class="forklift" class-name="card-panel-icon" />
        </div>
        <div class="card-panel-description">
          <div class="card-panel-text">
            非道路移动机械数量
          </div>
          <count-to :start-val="0" :end-val="indexvo.noroadCount" :duration="20" class="card-panel-num" />
        </div>
      </div>
    </el-col>

  </el-row>
</template>

<script>
  import CountTo from 'vue-count-to'
  import {
    getControl,
    getIndexAll
  } from "@/api/other/index";
  export default {
    data() {
      return {
        erinfo: {},
        indexvo: {}
      }
    },
    components: {
      CountTo,
    },
    mounted() {
      this.getErInfo()
      this.getStatistics()
    },
    methods: {
      handleSetLineChartData(type) {
        this.$emit('handleSetLineChartData', type)
      },
      getErInfo() {
        this.loading = true;
        getControl().then(response => {
          console.log(response)
          this.erinfo = response.data
        });
      },
      getStatistics() {
        getIndexAll().then(response => {
          this.indexvo = response.data
        });
      }
    }
  }

</script>

<style lang="scss" scoped>
  .circle {
    display: block;
    float: left;
    width: 15px;

    height: 15px;

    background-image: radial-gradient(#7fee1d, #7fb80e);

    -moz-border-radius: 15px;

    -webkit-border-radius: 15px;

    border-radius: 15px;

  }


  .panel-group {
    margin-top: 18px;

    .card-panel-col {
      margin-bottom: 32px;
    }

    .card-panel {
      height: 108px;
      cursor: pointer;
      font-size: 12px;
      position: relative;
      overflow: hidden;
      color: #666;
      background: #fff;
      box-shadow: 4px 4px 40px rgba(0, 0, 0, .05);
      border-color: rgba(0, 0, 0, .05);

      &:hover {
        .card-panel-icon-wrapper {
          color: #fff;
        }

        .icon-people {
          background: #40c9c6;
        }

        .icon-message {
          background: #36a3f7;
        }

        .icon-money {
          background: #36a3f7;
        }

        .icon-shopping {
          background: #34bfa3
        }
      }

      .icon-people {
        color: #40c9c6;
      }

      .icon-message {
        color: #36a3f7;
      }

      .icon-money {
        color: #36a3f7;
      }

      .icon-shopping {
        color: #34bfa3
      }

      .card-panel-icon-wrapper {
        float: left;
        margin: 5px 0 0 14px;
        padding: 16px;
        transition: all 0.38s ease-out;
        border-radius: 6px;
      }

      .card-panel-icon {
        float: left;
        font-size: 68px;
      }

      .card-panel-description {
        float: right;
        font-weight: bold;
        margin: 26px;
        margin-left: 0px;

        .card-panel-text {
          line-height: 18px;
          color: rgba(0, 0, 0, 0.45);
          font-size: 20px;
          margin-bottom: 12px;
        }

        .card-panel-num {
          font-size: 20px;
        }
      }
    }
  }

  @media (max-width:550px) {
    .card-panel-description {
      display: none;
    }

    .card-panel-icon-wrapper {
      float: none !important;
      width: 100%;
      height: 100%;
      margin: 0 !important;

      .svg-icon {
        display: block;
        margin: 14px auto !important;
        float: none !important;
      }
    }
  }

</style>
